<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.dnms.model.*,com.hs.core.cache.*" pageEncoding="utf-8"%>
 <% 
  DnmsMagazine obj = (DnmsMagazine)request.getAttribute("obj"); 
  
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script language="javascript" type="text/javascript" src="<%=basePath%>common/uploadify/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>common/javascripts/My97DatePicker/WdatePicker.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>common/uploadify/jquery.uploadify.v2.1.4.js"></script>
<script type="text/javascript" src="<%=basePath%>common/uploadify/swfobject.js"></script>
<LINK rel=stylesheet type=text/css href="<%=basePath%>common/uploadify/uploadify.css"/>  
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script>  

<script language="javascript" type="text/javascript">
function dataPro(id){
	window.location.href="";

}
 /**方剂信息保存*/ 
function saveBookinfo(){  
 	var bookname = document.getElementById("bookname").value; 
 	var bookcontent = document.getElementById("bookcontent").value;  
  	 
	if(isNull(bookname)){
		alert("请输入书名！");
		return; 
    } 
    dataProhelper.addBookinfo(bookname,bookcontent,'',<%=obj.getId()%>,callback4addBook);
}
function callback4addBook(message){ 
	   var cellFunctions = [    
          function(item) {   
           	return item.bookname;
          }, 
          function(item) {  
           	return item.bookcontent;
          }, 
          function(item) {  
           	return "<a href=javaScript:onclick=delBook('"+item.id+"');>删 除</a><input type=hidden value='"+item.id+"' name='preid_"+item.id + "' id='preid_"+item.id+"/>";
          }
      ];    
     var index = message.indexOf("$");  
     var bookid = message.substring(0,index); 
     var rowdata = message.substring(index+1); 
     var data = eval('('+rowdata+')');   
      DWRUtil.addRows("booklist", data, cellFunctions,{
          rowCreator:function(options) { //自定义 tr 的创建行为 
          var trobj = document.createElement("tr");   
          trobj.setAttribute("id","book_"+bookid);  
          return trobj; 
     },cellCreator:function(options) {
	var cell = document.createElement("td"); 
	//if(options.cellNum==0) {//表示第一列，以此类推   
	//  	cell.width = "80%";
	//	}else{
	//	    cell.width = "10%";
	//    cell.align="center";
	     
	//}
	return cell;
}, escapeHtml:false
     });
    document.getElementById("bookname").value=''; 
 	document.getElementById("bookcontent").value=''; 
    alert('古书籍引用信息保存成功！');   
}



function delBook(id){
	if(confirm("确认要删除该古书籍引用吗？")){
	        dataProhelper.delBookinfo(id,callback4delBook);
    }
} 
function callback4delBook(data){   
	var tbody  = document.getElementById("booklist");// tbody 的id 
    var rowobj = document.getElementById("book_"+data);  
    tbody.removeChild(rowobj);
}
</script>
</head>
<body>
 
<div class="deta_proce" style="border-top:none;margin-left:0"> 
    <div>
        <table border="0" cellspacing="0" cellpadding="0" class="atta_tab">
          <caption>古书籍信息</caption>  
          <tr>  
            <th width="20%">书名</th>
            <th width="70%">引用内容</th> 
            <th width="10%">删除</th> 
          </tr>
          <tbody id=booklist>
           <%if(obj != null && !obj.getBookset().isEmpty()){
                Set bookset = obj.getBookset();
                Iterator iter = bookset.iterator();
          		while(iter.hasNext()){
          			DnmsOldfile book = (DnmsOldfile)iter.next();
           %>
	           <tr id=book_<%=book.getId() %>>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=book.getBookname()%></td>
	           <td style="word-break:break-all;over-flow:hidden;"><%=book.getContent()==null?"":book.getContent()%></td>
 	           <td><a href="javaScript:onclick=delBook('<%=book.getId() %>')">删除</a></td>
	           </tr>
           <%}} %>
           </tbody>
        </table>
         <table border="0" cellspacing="0" cellpadding="0"> 
          <tr>
            <td width="15%">书名：</td> 
            <td colspan=3 width="90%" ><input type="text" name="bookname" id="bookname" style="width:99%"/></td> 
          </tr>  
          <tr>
            <td width="15%">引用内容：</td> 
            <td width="80%"><textarea name="bookcontent" id="bookcontent" rows=3 style="width:99%"></textarea></td>
            <td width="10%"><input onclick="saveBookinfo()" type="button" value=" 保 存 " class="but_2"/></td>
            
         </tr>
          
        </table> 
       
    </div>
</div>
</body>
</html>

